package StudyCode.summary.zipfile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class StringCompressToFile {
	public static void compressToFile(File dest, String str)
			throws IOException {
		if (str == null) {
			return;
		}

		GZIPOutputStream zipOut = null;

		try {
			zipOut = new GZIPOutputStream(new FileOutputStream(dest));
			zipOut.write(str.getBytes());
		} finally {
			if (zipOut != null) {
				try {
					zipOut.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
